package cn.bs.allensocket;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by Allen on 2014/11/1.
 */
public class AllenMyServerA {
    private int port=7011;
    public void run()throws IOException{
        ServerSocket server = new ServerSocket(port);
        Socket socket = server.accept();
        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        PrintWriter out = new PrintWriter(
                new BufferedWriter(
                        new OutputStreamWriter(socket.getOutputStream())),true);
        while(true){
            String str = in.readLine();
            if ("end".equals(str))break;
            System.out.println("Server:" + str);
            out.println(str);
        }
        socket.close();
    }
}
